package com.comtop.topcloud.device.controller;


import com.comtop.topcloud.device.model.mysql.EnergyEquipmentMonitorRefTag;
import com.comtop.topcloud.device.service.EnergyEquipmentMonitorRefTagService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/energyEquipmentMonitor")
public class EnergyEquipmentMonitorRefController {


    @Resource
    private EnergyEquipmentMonitorRefTagService energyEquipmentMonitorRefTagService;

    // 更新缓存中的 EnergyEquipmentMonitorRef
    @PostMapping("/update-cache")
    public ResponseEntity<String> updateCacheEquipmentMonitorRef(@RequestBody List<EnergyEquipmentMonitorRefTag> energyEquipmentMonitorRefTags) {
        try {
            energyEquipmentMonitorRefTagService.updateCacheEquipmentMonitorRefTag(energyEquipmentMonitorRefTags);
            return ResponseEntity.ok("Cache updated successfully");
        } catch (Exception e) {
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error updating cache: " );
        }
    }
}
